import { Pipe, PipeTransform } from "@angular/core";
import { GroupedIncidentsModel } from "../../../controversies/components/controversiesSummary/models/groupedIncidents.model";
import { IncidentCategory } from "../../../../../../shared/models/incidentCategory.enum";

@Pipe({
    name: 'categoryIncidents'
})
export class CategoryIncidentsPipe implements PipeTransform {
    transform(data: GroupedIncidentsModel[], category: IncidentCategory) {
        let categoryIncidents = data.filter(x => x.key == IncidentCategory[category].toString());
        return categoryIncidents.length == 1 ? categoryIncidents[0].incidents : [];
    }
}